package modules

import (
	"errors"

	"missevanbot/models"
	"missevanbot/utils"
)

// InitBot queries information of the bot.
func InitBot(room *models.Room) (err error) {
	n, c := cookie(room.ID, room.Cookie)
	if c == "" {
		// Make sure the cookie is not empty.
		err = errors.New("cookie empty")
		return
	}
	room.BotNic = n
	room.BotCookie = c
	user, err := BotInfo(c)
	if err != nil {
		return
	}
	room.BotUser = user
	return
}

func IsSupervisor(uid int64) bool {
	return rdb.SIsMember(ctx, KeySupervisor, utils.Itoa(uid)).Val()
}
